fix(init): flash init show usage menu when called without arguments#235
fix(init): flash init show usage menu when called without arguments#235
flash init show usage menu when called without arguments#235Conversation
There was a problem hiding this comment.
Pull request overview
Updates the flash init CLI behavior so invoking it without a project argument shows a usage/help panel and exits, making “initialize in current directory” an explicit flash init ..
Changes:
- Added an early-exit usage panel for
flash initwhen called with no positional argument. - Updated init logic so only
flash init .initializes the current directory (no longer the default when omitted). - Added/updated unit tests to cover the new no-args behavior (exit code, no skeleton creation, usage output).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/runpod_flash/cli/commands/init.py |
Adds no-args usage panel + exit and adjusts current-directory branching to require .. |
tests/unit/cli/commands/test_init.py |
Adds tests validating no-args exit behavior, output, and that no skeleton is created. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
flash init show usage menu when called without arguments
runpod-Henrik
left a comment
There was a problem hiding this comment.
Code Review — PR #235: flash init usage menu
The init.py change is clean — showing usage panel when no args instead of silently initializing in cwd is good UX.
Note: This PR shares a large diff overlap with PRs #221 and #237 (aiohttp session consolidation, api_key_context.py removal, DEFAULT_WORKERS_MIN change, get_api_key() migration). The bugs found in those shared components apply here too:
- HIGH —
Authorizationheader sent to presigned S3 URLs inapp.py(see PR #221 review) - HIGH — Per-request API key propagation from LB to workers silently removed (see PR #221 review)
- HIGH —
uv pip installfails without active venv inupdate.py(see PR #237 review, ifupdate.pyis included)
The init.py change itself has no issues. Tests cover all three modes (flash init, flash init ., flash init name).
dfd74ae to
e57fdf5
Compare
1a13609 to
45bd8c1
Compare
KAJdev
left a comment
There was a problem hiding this comment.
just that one fix and then should be good to go
Previously `flash init` with no arguments silently initialized in the current directory (same as `flash init .`). Now it shows a usage panel with examples and exits, matching expected CLI behavior: - `flash init` prints usage menu - `flash init .` initializes in current directory - `flash init <name>` creates new project folder
Replace hand-crafted usage text with ctx.get_help() to prevent drift when CLI options change. Update argument help text to clarify that '.' must be explicitly passed for current-directory init.
Syntax error from commit message text accidentally appended to a docstring in test_init.py, breaking ruff format checks.
c73c85a to
d1a240c
Compare
KAJdev review feedback: Panel(ctx.get_help()) renders an empty panel. Use console.print(ctx.get_help()) directly instead.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Typer help strings contain [OPTIONS] which Rich interprets as markup tags, causing MarkupError or mangled output. Pass markup=False and highlight=False to console.print. Test updated to verify this.
runpod-Henrik
left a comment
There was a problem hiding this comment.
1. Implementation — behavior change
Clean change. The None branch was cleanly split from "." — previously if project_name is None or project_name == "." routed both to CWD init; now only "." does. The ctx.get_help() approach is the right Typer idiom: it surfaces the same text as flash init --help, is automatically kept in sync as the command signature changes, and the markup=False, highlight=False flags prevent Rich from misinterpreting brackets in the output as markup.
raise typer.Exit(0) is correct — showing help is not an error, so exit code 0 is right.
2. Tests
Question: no CLI-level test for Typer context injection
All tests call init_command(mock_typer_ctx, ...) directly, bypassing Typer's wiring. The unit tests can't verify that ctx: typer.Context is correctly recognized and injected when invoked as a real CLI command. If something were misconfigured at the app.command() registration level, the unit suite would stay green while the CLI silently broke.
Adding a single CliRunner test covers this:
from typer.testing import CliRunner
from runpod_flash.cli.main import app
def test_no_args_via_cli():
result = CliRunner().invoke(app, ["init"])
assert result.exit_code == 0
assert "flash init" in result.outputThis is low risk given that typer.Context injection is well-established, but it's the one gap the current tests leave open.
The three new TestInitCommandNoArgs tests cover the right cases — exit code, no skeleton created, help printed with correct kwargs.
Deleted test (test_init_current_directory_with_none) — correct to remove. Its replacement is TestInitCommandNoArgs, which is clearer.
Nits
test_no_args_prints_usage_infochecks"flash init" in help_argbut the string comes from the mock fixture ("Usage: flash init [OPTIONS] [PROJECT_NAME]"). The test doesn't explicitly assert thatctx.get_help()was called —mock_typer_ctx.get_help.assert_called_once()would make the intent clearer.- The raw
--helpoutput is functional but a custom panel with two concrete examples (flash init .andflash init my-project) would be more discoverable for users who don't know the dot convention. Enhancement only — not blocking.
Verdict: PASS WITH NITS
The behavior change is clean and correct. The one meaningful gap is a CLI-level integration test to confirm Typer's context injection. The nits are minor.
🤖 Reviewed by Henrik's AI-Powered Bug Finder
Address Henrik review feedback: - Add CLI-level test via CliRunner to verify Typer context injection - Assert ctx.get_help() was called in no-args test
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Addressed feedback from review:
Nits noted (custom panel with examples) -- not blocking per review, can follow up separately. |
Summary
flash initwith no arguments now prints the built-in Typer help text and exits instead of silently initializing in the current directoryflash init .continues to initialize in the current directory (unchanged)flash init <name>continues to create a new project folder (unchanged)Before:
flash initandflash init .had identical behavior -- both initialized in cwd.After:
flash initshows help text;flash init .is the explicit way to initialize in cwd.Test plan
Nonecreates skeleton (removed -- behavior changed)make quality-checkpassesflash init,flash init .,flash init <name>